package com.itheima.mapper;

import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {
//    @Select("SELECT count(*) FROM emp e LEFT JOIN dept d on d.id = e.dept_id")
//    long selectTotal();
//
//    @Select("SELECT e.*,d.name deptName FROM emp e LEFT JOIN dept d on d.id = e.dept_id " +
//            "limit #{start},#{pageSize}")
//    List<Emp> selectByPage(Integer start, Integer pageSize);
//    @Select("select e.*,d.name deptName from emp e left join dept d on d.id = e.dept_id")
//    List<Emp> list();

    List<Emp> list(EmpQueryParam param);


    //主键回显
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into emp (username,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time)" +
            "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void add(Emp emp);

//    @Select("select * from emp")
//    List<Emp> getAll();


    void delete(List<Integer> ids);
    //根据查询员工信息
    @Select("select * from emp where id = #{id}")
    Emp selectEmp(Integer id);

    void updateById(Emp emp);
    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp getUsernameAndPassword(Emp emp);
    @Select("select count(*) from emp where dept_id=#{deprtId}")
    Long selectCountByDeptId(Integer deptId);
    //
    Emp getById2(Integer id);
    //查询员工各个职位以及人数
    @MapKey("jobname")
    List<Map<String,Object>> countJob();
    @MapKey("gender")
    List<Map> countGender();
    @MapKey("degree")
    List<Map> CountStudentDegree();
    @MapKey("className")
    List<Map> classStudentCount();
}
